﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using BussinessLayer;
namespace projectQLDV
{
    public partial class frmChucVu : DevExpress.XtraEditors.XtraForm
    {
        private frmMain frmM;
        private int idCV;
        private string tenCV;
        private string mieutaCV;
        tblChucvu _chucvu = new tblChucvu();
        public frmChucVu(frmMain frm)
        {
            InitializeComponent();
            frmM = frm;
            idCV = -1;

        }
        public frmChucVu(frmMain frm,int id,string _tenchucvu,string _mieutachucvu)
        {
            InitializeComponent();
            frmM = frm;
            //idCV = -1;
            idCV = id;
            tenCV = _tenchucvu;
            mieutaCV = _mieutachucvu;
            showform();
        }

        private void frmChucVu_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (idCV == -1)
                frmM.frmThemCV_isShown=false;
            else frmM.frmCapNhatCV_isShown = false;

        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
            this.Dispose();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtchucvu.Text != "" && txtmieuta.Text != "")
            {

                _chucvu.chucvu(this.idCV, txtchucvu.Text, txtmieuta.Text, true);
                frmM.GridViewChucvu();
            }
            else
                MessageBox.Show("Chưa nhập đầy đủ thông tin", "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }
        private void showform()
        {
            txtchucvu.Text = tenCV;
            txtmieuta.Text = mieutaCV;
        }

        private void btnSaveAndExit_Click(object sender, EventArgs e)
        {
            btnSave_Click(sender, e);
            btnExit_Click(sender, e);
        }
    }
}